<template>
	<view class="update-item bcl-white relative">
		<!-- 用户信息 -->
		<view class="box">
			<view class="uni-avatar mr-10">
				<image :src="item.avatar || defaultImage" />
			</view>

			<view>
				<view class="name bold fz-15">{{ item.usname }}</view>
				<view class="date cl-second fz-12 mt-5">{{ item.updated_at }}</view>
			</view>
		</view>

		<!-- 内容 -->
		<view class="mt-10 pl-40 cl-basic fz-12">
			<view class="mb-10 cl-second" v-if="item.backToDesc">回复{{ item.backToDesc }}：</view>
			<view style="overflow: auto;" v-html="item.desc"></view>
		</view>

		<!-- 附件 -->
		<view class="box box-between box-column-center pl-40 mt-10">
			<view @click="toFilesPage" v-if="item.files.length" >
				<text class="icon icon-annex fz-14"></text>
				<text>附件1123({{ item.files.length }})</text>
			</view>
			<view v-else></view>
			<view>
				<navigator :url="`/pages/index/modify?type=1&taskId=${item.task_id}&recordId=${item.id}`"
				 v-if="role != 'employer' && this.$store.state.userInfo.id != item.uid">
					<button class="uni-button uni-button-sm">
						回复TA
					</button>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "updateItem",
		props: {
			item: {
				type: Object,
				default: {},
			},

			role: {
				type: String,
				default: "",
			},
		},

		data() {
			return {
				defaultImage: this.$config.default,
			};
		},

		methods: {
			toFilesPage() {
				uni.setStorageSync("currentFiles", this.item.files);
				uni.navigateTo({
					url: `/pages/index/files`,
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.update-item {

		// 好评率
		.percent {
			position: absolute;
			top: 0;
			right: 0;
		}
	}
</style>
